<template>
  <TheCreateForm
    ref="formRefs"
    title="退款记录"
    :api="api"
    mode="view"
    :form.sync="form"
    :options="formOptions"
    :renderFunc="renderFunc"
  >
    <template v-slot:changeAmount="{ slotProps }">
      {{ form.changeAmount | filterPriceFormat }}
    </template>
    <template v-slot:approvalState="{ slotProps }">
      {{ form.approvalState | filterRechargeChangeState }}
      <div>
        {{
          form.approvalState == "APPROVAL_REJECTED"
            ? `原因:${form.approvalRefuseReason}`
            : ""
        }}
      </div>
    </template>
  </TheCreateForm>
</template>

<script>
import { apiMemberBalanceRecordDetail } from "@/api/recharge.js";
import { apiMerchantPage } from "@/api/storeManager.js";

export default {
  components: {},
  data() {
    return {
      api: apiMemberBalanceRecordDetail,
      form: {},
      formOptions: [
        {
          type: "input",
          field: "approvalState",
          title: "状态",
          slot: "approvalState",
        },
        {
          type: "select",
          field: "dataId",
          title: "退款商家",
          disabled: true,
          api: apiMerchantPage,
          params: { pageNum: 1, pageSize: -1 },
          optionKey: "merchantContactName",
          optionValue: "merchantId",
          options: [],
        },

        {
          type: "input-number",
          field: "changeAmount",
          title: "退款金额",
          disabled: true,
          slot:'changeAmount'
        },
        {
          type: "select",
          field: "approvalPayMethod",
          title: "退款渠道",
          placeholder: "请选择...",
          options: [
            { label: "支付宝", value: "ALIPAY" },
            { label: "微信", value: "WECHAT" },
            { label: "银行卡", value: "BANK" },
            { label: "其他", value: "OTHER" },
          ],
          disabled: true,
        },
        {
          type: "upload",
          field: "approvalCertificate",
          title: "转账凭证",
          disabled: true,
        },
        {
          type: "textarea",
          field: "approvalRemark",
          title: "备注",
          disabled: true,
        },
        {
          type: "input",
          field: "initiateName",
          title: "发起人",
          default: "",
        },
        {
          type: "input",
          field: "createTime",
          title: "发起时间",
          default: "",
        },

        {
          type: "input",
          field: "approvalName",
          title: "审批人",
          default: "",
        },
        {
          type: "input",
          field: "approvalTime",
          title: "审批时间",
          default: "",
        },
        {
          type: "input",
          field: "completionTime",
          title: "完成时间",
          default: "",
        },
      ],
    };
  },
  mounted() {},
  methods: {
    open(row) {
      this.$refs.formRefs.open(row);
    },
    renderFunc(res){
      return {
        ...res.data,
        approvalCertificate:res.data.approvalCertificate.split(',')
      }
    }
  },
};
</script>

